package com.heima;

import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.FileInputStream;

// @SpringBootTest(classes = MinioApplication)
// @RunWith(SpringRunner.class)
public class Main {
    public static void main(String[] args) {

        try {

            FileInputStream fileInputStream = new FileInputStream("E:\\plugins\\js\\index.js");
            //1,获取ninio.的链接信息创建一个ninio.的客户端
            MinioClient minioclient = MinioClient.builder().credentials("minio", "minio123").endpoint("http://192.168.200.130:9000").build();
            //2.上传
            PutObjectArgs putobjectArgs = PutObjectArgs.builder()
                    .object("/plugins/js/axios.min.js")
                    .contentType("text/js")
                    .bucket("leadnews")//桶名称，后理界面创建的桶一致即可
                    .stream(fileInputStream, fileInputStream.available(),-1).build();
            minioclient.putObject(putobjectArgs);

            System.out.println("http://192.168.200.130:9000/leadnews");//访问路径
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}